package com.lepu.app.fun.my.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class BeanMyAddressManage implements Serializable {

	private static final long serialVersionUID = 7996652381230447408L;
	
	public String UserID;
	public String AID;
	public String ReceiverName;
	public String ReceiverPhone;
	public String AreaID;
	public String ReceiverAddress;
	public String IsDefault;//1 默认地址 0 非默认
	public String RecordCreateTime;
	
	public String ZipCode;
	
	public static ArrayList<BeanMyAddressManage> parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONArray dataArray = (JSONArray) obj1.get("ListInfo");
			
			result = dataArray.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		ArrayList<BeanMyAddressManage> testArraylist = gson.fromJson(result,
				new TypeToken<List<BeanMyAddressManage>>() {
				}.getType());
		return testArraylist;
	}
	
	
	public static ArrayList<BeanMyAddressManage> getDataTestList()
	{
		ArrayList<BeanMyAddressManage> dataList = new ArrayList<BeanMyAddressManage>();
		
		for(int i=0;i<9;i++)
		{
			BeanMyAddressManage item = new BeanMyAddressManage();
			item.AID = String.valueOf(i);
			item.ReceiverName = "test name";
			item.ReceiverPhone = "137 17936 555";
			item.AreaID = "test AreaID";
			item.ReceiverAddress = "test address";
			item.IsDefault = "0";
			dataList.add(item);
		}
		return dataList;
	}
}
